package com.jhd.jiangxi.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jhd.jiangxi.vo.Login;
import com.jhd.jiangxi.vo.VaccineLots;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

public class ListString {
    public static String list2str(List<Login> list){
        JSONArray jsonArray = (JSONArray) JSONArray.toJSON(list);
        System.out.println(jsonArray.toString());
        return jsonArray.toJSONString();
    }
    public static List<Login> str2list(String view){
        List<Login> list = JSON.parseArray(view, Login.class);
        return list;
    }
    public static String lots2Str(VaccineLots vaccineLots){
        JSONObject jsonObject = (JSONObject) JSONObject.toJSON(vaccineLots);
        System.out.println(jsonObject.toString());
        return jsonObject.toJSONString();
    }
    public static VaccineLots str2Lots(String view){
        VaccineLots vaccineLots = JSON.parseObject(view, VaccineLots.class);
        return vaccineLots;
    }
    public static Date getDate(String view) throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//注意月份是MM
        Date date = simpleDateFormat.parse(view);
        return date;
    }
}
